.class Lmyapp/updateManager$2;
.super Ljava/lang/Object;
.source "updateManager.java"

# interfaces
.implements Ljava/lang/Runnable;


# annotations
.annotation system Ldalvik/annotation/EnclosingClass;
    value = Lmyapp/updateManager;
.end annotation

.annotation system Ldalvik/annotation/InnerClass;
    accessFlags = 0x0
    name = null
.end annotation


# instance fields
.field final synthetic this$0:Lmyapp/updateManager;


# direct methods
.method constructor <init>(Lmyapp/updateManager;)V
    .locals 0

    .prologue
    .line 1
    iput-object p1, p0, Lmyapp/updateManager$2;->this$0:Lmyapp/updateManager;

    .line 228
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    return-void
.end method


# virtual methods
.method public run()V
    .locals 15

    .prologue
    .line 232
    :try_start_0
    new-instance v11, Ljava/net/URL;

    iget-object v12, p0, Lmyapp/updateManager$2;->this$0:Lmyapp/updateManager;

    # getter for: Lmyapp/updateManager;->apkUrl:Ljava/lang/String;
    invoke-static {v12}, Lmyapp/updateManager;->access$4(Lmyapp/updateManager;)Ljava/lang/String;

    move-result-object v12

    invoke-direct {v11, v12}, Ljava/net/URL;-><init>(Ljava/lang/String;)V

    .line 234
    .local v11, "url":Ljava/net/URL;
    invoke-virtual {v11}, Ljava/net/URL;->openConnection()Ljava/net/URLConnection;

    move-result-object v3

    check-cast v3, Ljava/net/HttpURLConnection;

    .line 235
    .local v3, "conn":Ljava/net/HttpURLConnection;
    invoke-virtual {v3}, Ljava/net/HttpURLConnection;->connect()V

    .line 236
    invoke-virtual {v3}, Ljava/net/HttpURLConnection;->getContentLength()I

    move-result v9

    .line 237
    .local v9, "length":I
    invoke-virtual {v3}, Ljava/net/HttpURLConnection;->getInputStream()Ljava/io/InputStream;

    move-result-object v8

    .line 239
    .local v8, "is":Ljava/io/InputStream;
    new-instance v6, Ljava/io/File;

    const-string v12, "/sdcard/updatedemo/"

    invoke-direct {v6, v12}, Ljava/io/File;-><init>(Ljava/lang/String;)V

    .line 240
    .local v6, "file":Ljava/io/File;
    invoke-virtual {v6}, Ljava/io/File;->exists()Z

    move-result v12

    if-nez v12, :cond_0

    .line 241
    invoke-virtual {v6}, Ljava/io/File;->mkdir()Z

    .line 243
    :cond_0
    const-string v1, "/sdcard/updatedemo/UpdateDemoRelease.apk"

    .line 244
    .local v1, "apkFile":Ljava/lang/String;
    new-instance v0, Ljava/io/File;

    invoke-direct {v0, v1}, Ljava/io/File;-><init>(Ljava/lang/String;)V

    .line 245
    .local v0, "ApkFile":Ljava/io/File;
    new-instance v7, Ljava/io/FileOutputStream;

    invoke-direct {v7, v0}, Ljava/io/FileOutputStream;-><init>(Ljava/io/File;)V

    .line 247
    .local v7, "fos":Ljava/io/FileOutputStream;
    const/4 v4, 0x0

    .line 248
    .local v4, "count":I
    const/16 v12, 0x400

    new-array v2, v12, [B

    .line 251
    .local v2, "buf":[B
    :cond_1
    invoke-virtual {v8, v2}, Ljava/io/InputStream;->read([B)I

    move-result v10

    .line 252
    .local v10, "numread":I
    add-int/2addr v4, v10

    .line 253
    iget-object v12, p0, Lmyapp/updateManager$2;->this$0:Lmyapp/updateManager;

    int-to-float v13, v4

    int-to-float v14, v9

    div-float/2addr v13, v14

    const/high16 v14, 0x42c80000    # 100.0f

    mul-float/2addr v13, v14

    float-to-int v13, v13

    invoke-static {v12, v13}, Lmyapp/updateManager;->access$5(Lmyapp/updateManager;I)V

    .line 255
    iget-object v12, p0, Lmyapp/updateManager$2;->this$0:Lmyapp/updateManager;

    # getter for: Lmyapp/updateManager;->mHandler:Landroid/os/Handler;
    invoke-static {v12}, Lmyapp/updateManager;->access$6(Lmyapp/updateManager;)Landroid/os/Handler;

    move-result-object v12

    const/4 v13, 0x1

    invoke-virtual {v12, v13}, Landroid/os/Handler;->sendEmptyMessage(I)Z

    .line 256
    if-gtz v10, :cond_2

    .line 258
    iget-object v12, p0, Lmyapp/updateManager$2;->this$0:Lmyapp/updateManager;

    # getter for: Lmyapp/updateManager;->mHandler:Landroid/os/Handler;
    invoke-static {v12}, Lmyapp/updateManager;->access$6(Lmyapp/updateManager;)Landroid/os/Handler;

    move-result-object v12

    const/4 v13, 0x2

    invoke-virtual {v12, v13}, Landroid/os/Handler;->sendEmptyMessage(I)Z

    .line 264
    :goto_0
    invoke-virtual {v7}, Ljava/io/FileOutputStream;->close()V

    .line 265
    invoke-virtual {v8}, Ljava/io/InputStream;->close()V

    .line 272
    .end local v0    # "ApkFile":Ljava/io/File;
    .end local v1    # "apkFile":Ljava/lang/String;
    .end local v2    # "buf":[B
    .end local v3    # "conn":Ljava/net/HttpURLConnection;
    .end local v4    # "count":I
    .end local v6    # "file":Ljava/io/File;
    .end local v7    # "fos":Ljava/io/FileOutputStream;
    .end local v8    # "is":Ljava/io/InputStream;
    .end local v9    # "length":I
    .end local v10    # "numread":I
    .end local v11    # "url":Ljava/net/URL;
    :goto_1
    return-void

    .line 261
    .restart local v0    # "ApkFile":Ljava/io/File;
    .restart local v1    # "apkFile":Ljava/lang/String;
    .restart local v2    # "buf":[B
    .restart local v3    # "conn":Ljava/net/HttpURLConnection;
    .restart local v4    # "count":I
    .restart local v6    # "file":Ljava/io/File;
    .restart local v7    # "fos":Ljava/io/FileOutputStream;
    .restart local v8    # "is":Ljava/io/InputStream;
    .restart local v9    # "length":I
    .restart local v10    # "numread":I
    .restart local v11    # "url":Ljava/net/URL;
    :cond_2
    const/4 v12, 0x0

    invoke-virtual {v7, v2, v12, v10}, Ljava/io/FileOutputStream;->write([BII)V

    .line 262
    iget-object v12, p0, Lmyapp/updateManager$2;->this$0:Lmyapp/updateManager;

    # getter for: Lmyapp/updateManager;->interceptFlag:Z
    invoke-static {v12}, Lmyapp/updateManager;->access$7(Lmyapp/updateManager;)Z
    :try_end_0
    .catch Ljava/net/MalformedURLException; {:try_start_0 .. :try_end_0} :catch_0
    .catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_1

    move-result v12

    if-eqz v12, :cond_1

    goto :goto_0

    .line 266
    .end local v0    # "ApkFile":Ljava/io/File;
    .end local v1    # "apkFile":Ljava/lang/String;
    .end local v2    # "buf":[B
    .end local v3    # "conn":Ljava/net/HttpURLConnection;
    .end local v4    # "count":I
    .end local v6    # "file":Ljava/io/File;
    .end local v7    # "fos":Ljava/io/FileOutputStream;
    .end local v8    # "is":Ljava/io/InputStream;
    .end local v9    # "length":I
    .end local v10    # "numread":I
    .end local v11    # "url":Ljava/net/URL;
    :catch_0
    move-exception v5

    .line 267
    .local v5, "e":Ljava/net/MalformedURLException;
    invoke-virtual {v5}, Ljava/net/MalformedURLException;->printStackTrace()V

    goto :goto_1

    .line 268
    .end local v5    # "e":Ljava/net/MalformedURLException;
    :catch_1
    move-exception v5

    .line 269
    .local v5, "e":Ljava/io/IOException;
    invoke-virtual {v5}, Ljava/io/IOException;->printStackTrace()V

    goto :goto_1
.end method
